const express = require('express');
const tourController = require('../controller/tourController.js')
const authController = require('../controller/authController');
const reviewRouter = require('../routes/reviewRoute')
//const reviewController = require('../controller/reviewController');

const router = express.Router();

// tours/6498626cb83db74304591be4 嵌套路由
// router.route('/:tourId/reviews').post(
//     authController.protect,
//     authController.restrictTo('user'),
//     reviewController.createReview
//     )
// use路由重定向？
router.use('/:tourId/reviews',reviewRouter);

//router.param('id',tourController.chickId)
router.route('/top-5-cheap').get(tourController.aliasTopTours,tourController.getAllTour);
router.route('/tour-stats').get(tourController.getTourStats);
router.route('/monthly-plan/:year').get(tourController.getMonthlyPlan);
router.route('/').get(authController.protect,tourController.getAllTour).post(tourController.createTour);
router.route('/:id').get(tourController.getTour)
.patch(tourController.updateTour)
.delete(authController.protect,authController.restrictTo('admin','lead-guide'),tourController.deleteTour);


module.exports = router